//START build
//start
var lib=(function(){
var PLAYER=function(){}
	PLAYER.fn             = PLAYER.prototype;
 	PLAYER.fn.constructor = PLAYER;		
	window.TOOLS          = PLAYER;
			
})()
TOOLS.getCoordinates = function( e , id ){
    x = e.clientX;
    y = e.clientY;
    document.getElementById(id).innerHTML="Coordinates: (" + x + "," + y + ")";
}
TOOLS.appendJs=function(srcJs,end){	
    var head=document.getElementsByTagName('head')[0];
    var script=document.createElement("script"); 
    script.setAttribute("type","text/javascript"); 
    script.setAttribute("src",srcJs);// 在这里引入了a.js 
	if(!end){
        head.insertBefore(script,head.childNodes[0]); 
	}else{
	    head.appendChild(script);	
	}
}
TOOLS.require=function(srcJs){
    document.write('<script src="'+srcJs+'" type="text/javascript"></script>')	
}

//true 的触发顺序总是在 false 之前；
//如果多个均为 true，则外层的触发先于内层；
//如果多个均为 false，则内层的触发先于外层。

TOOLS.ready=function(callback){
	if(document.addEventListener){
		document.addEventListener(
		    "DOMContentLoaded",
		    function(){
			    document.removeEventListener("DOMContentLoaded",arguments.callee,false);
			    callback();
				console.log('removeEventListener');
				console.log(arguments.callee)
				
		    },
			false
		);
	}else if(document.attachEvent){
		document.attachEvent(
		    "onreadystatechange",
		    function(){
			    if ( document.readyState === "complete" ) {
				    document.detachEvent( "onreadystatechange", arguments.callee );
				    callback();
					console.log('detachEvent');
					//alert(arguments.callee)
			    }
		    }
		)
	 }
}
TOOLS.mkDiv=function(id,cssText,innerHTML,bl){
   var innerHTML =innerHTML || "";
   var body=document.getElementsByTagName('body')[0];
   var div = document.createElement("div");
   
   if(! bl ){
      div.id=id; 
   }
   div.className=id;
   div.innerHTML=innerHTML;
   div.style.cssText=cssText;
   body.insertBefore(div,body.childNodes[0]);	
}
//end
/********************************************/
//bind start
TOOLS.bind=function(scope){
	console.log('this')
	console.log(this)
	console.log('scope')
	console.log(scope)
    var fn = this;
    return function () {
        return fn.apply(scope);
    };
	
}

Function.prototype.__$bind$__ = function(){ 
//此句中的arguments指的是 __bind__函数的参数
  var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); 
  return function(){ 
    return fn.apply(object, 
	/*此句中的arguments指的是 函数fn的参数*/
      args.concat(Array.prototype.slice.call(arguments))); 
  }; 
}
;
Function.prototype.__$basebind$__ = function(scope){ 
    var fn = this;
    return function () {
        return fn.apply(scope);
    };
}
;
Function.__$proto$__=Function.prototype.__$proto$__={
	
	__$proto$__:{},
	__a__:function(){},
	__b__:function(){},
	__c__:function(){}
	
	};
//Function.__$proto$__.__$proto$__=Function.prototype;
//bind end
/********************************************/
;(function(window){  
var	
    undefined = "undefined",
    numid=0,
    doll = function(jQ) { };
	 	
    doll.fn = doll.prototype = {
	    constructor: doll
	}
	window.doll = doll;
})(window)
/********************************************/
doll.fullscreen = function (divObj) {
		
		if(typeof divObj=="undefined"){
			divObj=document.documentElement; 
		}
	    //$.doll._prof("#debug",divObj)
        if (divObj.requestFullscreen) {
			
            divObj.requestFullscreen();
			console.log("requestFullscreen()");
        }
        else if (divObj.msRequestFullscreen) {
            divObj.msRequestFullscreen();
			console.log("msRequestFullscreen()");
		}
        else if (divObj.mozRequestFullScreen) {
			
            divObj.mozRequestFullScreen();
			console.log("mozRequestFullScreen");
        }
        else if (divObj.requestFullscreen 
		|| ('webkitRequestFullScreen' in document.documentElement) ) 
		{    
		 
		    try{
					 //支持谷歌
					 // 对 Chrome 特殊处理，
					 // 参数 Element.ALLOW_KEYBOARD_INPUT 使全屏状态中可以键盘输入。
					if ( window.navigator.userAgent.toUpperCase().indexOf( 'CHROME' ) >= 0 ) {
						 console.log("chrome浏览正在器全屏webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT )")
						 divObj.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );					 
						 
					}else{		
				
                        divObj.webkitRequestFullscreen();
						console.log("webkitRequestFullscreen()");
					}
		     }catch(e){
				 //支持 safari5.1
				 divObj.webkitRequestFullScreen();
				 console.log(" safari5.1 浏览正在器全屏webkitRequestFullScreen")
				 
			 }
        }
		else{		     		 
			console.log("你的浏览器不支持全屏！");
		}
        //doll.inFullScreen = true;
		
        return;
      }
	  
	  
	  doll.exitFullscreen = function () {
        if (document.exitFullscreen) {
          document.exitFullscreen();
        }
        else if (document.msExitFullscreen) {
          document.msExitFullscreen();
        }
        else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen();
        }
        else if (document.webkitCancelFullScreen) {
			
          document.webkitCancelFullScreen();
        }
        //doll.inFullScreen = false;
		console.log("浏览退出全屏……");
        return;
      }	  
;	  
/********************************************/
//EListenCanvas start
if(typeof TOOLS ==="undefind"){
	var TOOLS =function(){}
	}
;(function(){
    var EListenCanvas = function(canvasid,w,h,bl){
		if(typeof w ==='undefined'){
		    w = 0 ;
			h = 0 ;	
		}
		this.type = 'resize';
		this.method = function(){
			if(typeof bl==='undefined'){
		    document.getElementById(canvasid).width  = window.innerWidth-w;
		    document.getElementById(canvasid).height = window.innerHeight-1-h;	
			console.log(document.getElementById(canvasid).width)
			}else{
			document.getElementById(canvasid).style.width  
			=parseInt(window.innerWidth*w)+'px' 
		   // document.getElementById(canvasid).style.height
		   // =parseInt(window.innerHeight*h)-1+'px'	
			console.log(document.getElementById(canvasid).style.width )					
			}
		}
		this.useCapture = false;
		this.add();		
		}  
		EListenCanvas.prototype.add=function(){
		    window.addEventListener( this.type, this.method, this.useCapture );	
			var themethod = this.method;
			EListenCanvas.ready(function(){
			   themethod()		
		    }) 
						
		}
		EListenCanvas.ready=function(callback){
	if(document.addEventListener){
		document.addEventListener(
		    "DOMContentLoaded",
		    function(){
			    document.removeEventListener("DOMContentLoaded",arguments.callee,false);
			    callback();
				console.log('-removeEventListener');
		    },
			false
		);
	}else if(document.attachEvent){
		document.attachEvent(
		    "onreadystatechange",
		    function(){
			    if ( document.readyState === "complete" ) {
				    document.detachEvent( "onreadystatechange", arguments.callee );
				    callback();
					console.log('-detachEvent');
			    }
		    }
		)
	 }
   }	
   window.EListenCanvas=TOOLS.EListenCanvas=EListenCanvas;	 
})()
//EListenCanvas end
//END
//var o={name:'koolfer'}
//var xxx=function(){
//	
//	
//	alert(this.name)
//	}.__$bind$__(o)
//	
//	xxx()
//	
/********************************************/
TOOLS.mkDivfx=function(id,cssText,innerHTML){
    var innerHTML =innerHTML || "";
    var body=document.getElementsByTagName('body')[0];
    var div = document.createElement("div");
    div.id=id;
    div.innerHTML=innerHTML;
    div.style.cssText=cssText;
    try{body.insertBefore(div,body.childNodes[0]);	}catch(e){ }
}
/********************************************/
window.mathExt=new Object();
mathExt.to60=function (sec){
	//转两个占位符表式 2变成02
	//to2placeholder
	 
	function to2 (n){
		return n<10 ?	0+""+n : n ;
	}		
	s=to2(sec%60)
	m=to2(
		 parseInt     (sec/60) % 60   
	);
	h=to2( parseInt (
		    ( sec/(60*60) ) % 60      
	));
	return  h!=0 ? h +":"+  m +":"+  s  :  m +":"+  s ;  
}
/********************************************/
